/*
 * @(#)GSProviderDAO.java
 * 
 * Project: BUS
 * 
 * Modify Information:
 * =============================================================================
 * Author          Date         Description
 *  ------------ ---------- ------------------------------------- 
 *  simonyi peng  2006-4-10    创建
 *  Jenny   Li    2006-4-17    添加方法queryConfirmableEmergyOrder,queryConfirmableEmergyOrderCount,
 *                              getSqlOfConfirmableEmergyOrder,updateTempOrderDetail,queryTempOrderDetail,
 *                              deleteTempOrderDetail,queryTempOrderDetail
 * Copyright Notice:
 * =============================================================================
 * Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room,
 * Science & Technology Building, No. 9 South Street, Zhong Guan Cun, Haidian
 * District, Beijing ,100081, China All rights reserved.
 * 
 * This software is the confidential and proprietary information of Beijing
 * HiTRUST Technology Co., Ltd. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in accordance
 * with the terms of the license agreement you entered into with HiTRUST.
 * 
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.bean.GSTempOrderBean;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.db.GSBaseDAO;
import com.hitrust.gs.util.exception.GSException;
import com.hitrust.gs.util.lang.IDGenerator;
import com.hitrust.gs.vo.GSBusEmergencyOrderConfirmDetailVO;
import com.hitrust.gs.vo.GSBusEmergencyOrderConfirmVO;
import com.hitrust.gs.vo.GSBusEmergencyOrderQueryVO;
import com.hitrust.gs.vo.GSOrderTempManufactureVO;
import com.hitrust.gs.vo.GSOrderTempVO;
//import com.hitrust.gs.vo.GSTempOrderVO;

public class GSTempOrderDAO  extends GSBaseDAO 
{

    public boolean isDeliverGoodsIdExist(String deliverGoodsId) throws GSException 
    {
        String tSql = "select * from gs_order_temp_detail where gs_deliver_goods_id = ?";
        boolean tFlag = false;
        Object[] tObj = {deliverGoodsId};
        try{
            ArrayList tList = this.executeQuery(new GSTempOrderBean(),tSql,tObj);
            if(tList.size() > 0){
                tFlag = true;
            }
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
        }
        return tFlag;
        
    }
    
    public Object[] isDeliverGoodsIdExistAndStatus(String deliverGoodsId) throws GSException {
        String tSql = "select * from gs_order_temp_detail where gs_deliver_goods_id = ?";
        String tFlag = "false";
        String tStatus = "";
        Object[] tObj = {deliverGoodsId};
        try{
            ArrayList tList = this.executeQuery(new GSTempOrderBean(),tSql,tObj);
            if(tList.size() > 0){
                tFlag = "true";
                tStatus = ((GSTempOrderBean)tList.get(0)).getOrderDetailStatus();
            }
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
        }
        return new Object[]{tFlag,tStatus};
        
    }
    
    /**
     * 建立一个新的订单
     * @param vo 订单数据值对象
     * @param ary 订单详细数据对象矢量
     * @throws GSException
     */
    public String insert(GSOperatorBean operBean,GSOrderTempVO vo,ArrayList ary) throws GSException {
        
        Connection conn = this.getConnetion();
        
        IDGenerator idg = new IDGenerator();
        
        String returnValue = "";
        try{
            conn.setAutoCommit(false);
            
            //构造订单号
            long id = idg.generatorID(vo.gs_workcorp_id,"02");
            String orderId = vo.gs_workcorp_id + idg.formatID(id,4) + "L";
            returnValue = orderId;
            
            
            //1 构造生成时间
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String createDate = sdf.format(new Date(System.currentTimeMillis()));
            
            //2 构造订单明细sql语句
            PreparedStatement pstmt = null;
            String sqlm = "insert into GS_ORDER_TEMP_DETAIL (" +
            "GS_ORDER_TEMPID," +
            "GS_ORDER_DETAIL_ID," + 
        	"GS_ORDER_CATEGORY," +
        	"GS_WORKCORP_ID," +
        	"GS_DELIVER_GOODS_ADDR," +
        	"GS_DELIVER_MODE," +
        	"GS_BALANCE_MODE," +
        	"GS_ORDER_CONTACT_NAME," +
        	"GS_ORDER_CONTACT_PHONE," +
        	"GS_CREATE_TIME," +
        	"GS_ORDER_DETAIL_STATUS," +
        	"GS_CONCENTRICITY_ID," +
        	"GS_PROVIDER_ID," +
        	"GS_MANUFACTURE_ID," +
        	"GS_GOODS_UNITPRICE," + 
        	"GS_DELIVER_GOODS_ID," +
        	"GS_SIGNIN_DATE," +
        	"GS_ORDER_COUNT," +
        	"GS_SIGNIN_COUNT," +
        	"GS_SIGNIN_PRICE," +
        	"GS_SIGNIN_PERSON," +
        	"GS_NOTES," +
        	"GS_LASTMODIFER_ID," +
        	"GS_LASTMODIFY_CONTENTS," +
        	"GS_LASTMODIFY_DATE," +
        	"GS_RECORDER_ID," +
        	"GS_BALANCE_CATEGORY_NO," +
        	"gs_balance_mode2"+
        	") values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";


            pstmt = conn.prepareStatement(sqlm);

            //3 计算订单总价
            //double totalPrice = 0;
            //BigDecimal buf = new BigDecimal("0");
            
            //4 对每一个产品
            for(int i=0;i<ary.size();i++){
                GSOrderTempManufactureVO dvo = (GSOrderTempManufactureVO)ary.get(i);
                //GSManufactureDAO mdao = new GSManufactureDAO();
                //GSManufactureBean mbean = mdao.getManufacture(dvo.manufactureid);
                
                //计算产品的总价
                //BigDecimal bd = new BigDecimal(new Double(mbean.getGs_manufacture_unitprice()).toString());
                //订单总价=产品单价*产品数量+初始订单总价
                //buf = bd.multiply(new BigDecimal(""+dvo.ordercount)).add(buf);
                
                //构造订单明细信息号
                String orderDetailId = orderId + idg.formatID(i,2);

                pstmt.setString(1,orderId);//
                pstmt.setString(2,orderDetailId);//
                pstmt.setString(3,"2");//
                pstmt.setString(4,vo.gs_workcorp_id);//
                pstmt.setString(5,vo.gs_deliver_goods_addr);//
                pstmt.setString(6,vo.gs_deliver_mode);//
                pstmt.setString(7,vo.gs_balance_mode);//
                pstmt.setString(8,vo.gs_deliveryman);//
                pstmt.setString(9,vo.gs_deliver_goods_phone);//
                pstmt.setString(10,createDate);//
                pstmt.setString(11,"1");//
                pstmt.setString(12,dvo.concentricityId);//
                pstmt.setString(13,dvo.providerId);//
                pstmt.setString(14,dvo.manufactureId);//
                pstmt.setDouble(15,dvo.referencePrice);//
                pstmt.setString(16,vo.gs_deliver_goods_id.trim());//
                pstmt.setString(17,vo.gs_signin_date.replace('/','-'));//
                pstmt.setDouble(18,Double.parseDouble(dvo.orderCount));//
                pstmt.setDouble(19,Double.parseDouble(dvo.orderCount));//
                pstmt.setDouble(20,dvo.signinPrice);//
                pstmt.setString(21,vo.gs_signin_person);//
                pstmt.setString(22,vo.gs_notes);//
                pstmt.setString(23,operBean.getGs_oper_id());//
                pstmt.setString(24,"应急采购订单录入");//
                pstmt.setString(25,createDate);//
                pstmt.setString(26,operBean.getGs_oper_id());//
                pstmt.setString(27,vo.balanceCategory);
                pstmt.setString(28,dvo.mode);
                //存入数据库
                pstmt.addBatch();
            }

            //6 提交订单明细
            pstmt.executeBatch();
            conn.commit();
            if(pstmt!=null) pstmt.close();
            
        }catch(Exception e){
            try{
            conn.rollback();
            }catch(SQLException sqle){}
            throw new GSException (GSException.E20051,GSException.E20051_MSG);
        }finally{
            try{
                conn.setAutoCommit(true);
            }catch(SQLException sqle){}
            close(conn);
        }
        
        return returnValue;

    }

    /**
     * 查询订单详细信息，FOR订单录入的结果页面显示
     * @param aOrderId
     * @return
     * @throws GSException
     */
    public ArrayList queryOrderDetail_(String aOrderId) throws GSException {
        ArrayList tList = new ArrayList();
        
        StringBuffer tSql = new StringBuffer("select ");
        	tSql.append("a.gs_workcorp_id as P1,a.gs_deliver_mode as P2,a.gs_balance_mode as P3,");
        	tSql.append("a.gs_deliver_goods_id as P4,a.gs_signin_date as P5,a.gs_signin_person as P6,");
        	tSql.append("a.gs_deliver_goods_addr as P7,a.GS_ORDER_CONTACT_NAME as P8,a.GS_ORDER_CONTACT_PHONE as P9,");
        	tSql.append("a.GS_SIGNIN_EXPLAIN as P10,a.GS_CONCENTRICITY_ID as P11,a.GS_MANUFACTURE_ID as P12,");
            tSql.append("b.GS_MANUFACTURE_NAME as P13,a.GS_ORDER_COUNT as P14,");
            tSql.append("b.GS_MANUFACTURE_SPEC as P15,b.GS_MANUFACTURE_TYPE as P16,b.GS_MANUFACTURE_BRAND as P17,");
            tSql.append("b.GS_QUANT_UNIT as P18,a.GS_SIGNIN_PRICE as P19,");
            tSql.append("a.GS_PROVIDER_ID as P20,c.gs_provider_name as P21,d.GS_ORG_NAME as P22,a.GS_NOTES as P23,");
            tSql.append("a.GS_ORDER_TEMPID,a.GS_ORDER_DETAIL_ID,a.GS_BALANCE_CATEGORY_NO as P24, a.gs_balance_mode2 as P25 ");
            tSql.append("from GS_ORDER_TEMP_DETAIL a,GS_MANUFACTURE b,GS_PROVIDER c,GS_ORGANIZATION d ");
            tSql.append("where a.GS_ORDER_TEMPID=? and a.GS_MANUFACTURE_ID= b.GS_MANUFACTURE_ID and ");
            tSql.append("b.gs_provider_id = c.gs_provider_id and a.GS_WORKCORP_ID = d.gs_org_id");
        Object[] tObj = {aOrderId};
        try{
            tList = executeQuery(new GSOrderTempManufactureVO(),tSql.toString(),tObj);
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
        }
        return tList;
        
    }
    /**
     * 查询待确认应急采购订单
     * @param aVO       查询参数VO
     * @param aOrg      可查询组织
     * @param aMap1     二级产品
     * @param aMap2     三级产品
     * @param pageNo    页号
     * @param pageSize  页大小
     * @return
     * @throws GSException
     */
    public ArrayList queryConfirmableEmergyOrder(GSBusEmergencyOrderQueryVO aVO,ArrayList aOrg,HashMap aMap1,HashMap aMap2,int pageNo,int pageSize) throws GSException{
        ArrayList tList = new ArrayList();
        StringBuffer tSql = new StringBuffer(this.getSqlOfConfirmableEmergyOrder(aVO,aOrg,aMap1,aMap2));
        tSql.append(" order by a.GS_LASTMODIFY_DATE desc,GS_DELIVER_GOODS_ID asc,GS_ORDER_TEMPID");
        GSLogWriter.info(this,tSql.toString());
        try{
            tList = this.executeQuery(new GSBusEmergencyOrderQueryVO(),tSql.toString(),null,pageNo,pageSize);
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
        }
        return tList;
    }
    /**
     * 查询待确认应急采购订单笔数
     * @param aVO       查询参数VO
     * @param aOrg      可查询组织
     * @param aMap1     二级产品
     * @param aMap2     三级产品
     * @return
     * @throws GSException
     */
    public int queryConfirmableEmergyOrderCount(GSBusEmergencyOrderQueryVO aVO,ArrayList aOrg,HashMap aMap1,HashMap aMap2) throws GSException{
        int tSize = 0;
        StringBuffer tSql = new StringBuffer("select count(*) from (");
        tSql.append(this.getSqlOfConfirmableEmergyOrder(aVO,aOrg,aMap1,aMap2));
        tSql.append(")");
//        tSql.append(" order by a.GS_LASTMODIFY_DATE desc");
        try{
            tSize = this.queryRowNum(tSql.toString(),null);
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);
        }
        return tSize;
    }
    /**
     * 查询待确认应急采购订单SQL
     * @param aVO           参数VO对象
     * @param aOrg          可查询组织
     * @param tManuf2       二级产品
     * @param tManuf3       三级产品
     * @return
     * @throws GSException
     */
    private String getSqlOfConfirmableEmergyOrder(GSBusEmergencyOrderQueryVO aVO,ArrayList aOrg,HashMap tManuf2,HashMap tManuf3) throws GSException{
        StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,b.GS_MANUFACTURE_NAME as P3,");
        tSql.append("b.GS_IS_TRADEFLAT_MANUFACTURE as P4,b.GS_MANUFACTURE_SPEC as P5,b.GS_MANUFACTURE_TYPE as P6,b.GS_MANUFACTURE_BRAND as P7,");
        tSql.append("a.GS_ORDER_COUNT as P8,b.GS_QUANT_UNIT as P9,d.GS_PROVIDER_SHORTNAME as P10,c.GS_ORG_NAME as P11,");
        tSql.append("a.GS_GOODS_UNITPRICE as P12,a.GS_ORDER_TEMPID as P15,");
        tSql.append("d.GS_PROVIDER_ID as P16,d.GS_IS_TRADEFLAT_PROVIDER as P17,a.GS_DELIVER_GOODS_ID as P18,");
        tSql.append("a.GS_SIGNIN_COUNT as P19,a.GS_SIGNIN_PRICE as P20,a.GS_ORDER_CATEGORY as P21,a.GS_LASTMODIFY_DATE,a.gs_balance_mode2 as P22");
        tSql.append(" from GS_ORDER_TEMP_DETAIL a,GS_MANUFACTURE b,GS_ORGANIZATION c,GS_PROVIDER d,GS_MANUFACTURE_CATEGORY e");
        tSql.append(" where a.GS_ORDER_DETAIL_STATUS='1' and a.GS_CONCENTRICITY_ID= b.GS_CONCENTRICITY_ID");
        tSql.append(" and a.GS_MANUFACTURE_ID= b.GS_MANUFACTURE_ID");
        tSql.append(" and a.GS_PROVIDER_ID=d.GS_PROVIDER_ID and a.GS_PROVIDER_ID=b.GS_PROVIDER_ID");
        tSql.append(" and a.GS_WORKCORP_ID=c.GS_ORG_ID");
        tSql.append(" and to_char(to_date(a.GS_CREATE_TIME,'YYYY-MM-DD HH24:mi:ss'),'YYYYMMDD') >='" + aVO.createDateStr + "'");
        tSql.append(" and to_char(to_date(a.GS_CREATE_TIME,'YYYY-MM-DD HH24:mi:ss'),'YYYYMMDD') <='" + aVO.createDateEnd + "'");
        tSql.append(" and b.GS_MANUFACTURE_CATEGORY_ID=e.GS_MANUFACTURE_CATEGORY_ID");
        if(aVO.providerName != null && !aVO.providerName.equals("")){
            tSql.append(" and (d.GS_PROVIDER_NAME ='"+ aVO.providerName + "'");
            tSql.append(" or d.GS_PROVIDER_SHORTNAME='" + aVO.providerName + "')");
        }
        if(aVO.deliverGoodsId != null && !aVO.deliverGoodsId.equals("")){
            tSql.append(" and a.GS_DELIVER_GOODS_ID = '" + aVO.deliverGoodsId + "'");
        }
        if(aVO.type.equals("0")){
            tSql.append(" and a.GS_ORDER_CATEGORY in('1','2')");
        }else{
            tSql.append(" and a.GS_ORDER_CATEGORY ='" + aVO.type + "'");
        }
        if(!aVO.orderDeptId.equals("0000")){
            tSql.append(" and a.GS_WORKCORP_ID = '" + aVO.orderDeptId + "'");
        }else{
            if(aOrg.size() > 0){
                tSql.append(" and a.GS_WORKCORP_ID in(");
                for(int i=0; i<aOrg.size();i++){
                    String tStr[] = (String[])aOrg.get(i);
                        if( i == aOrg.size()-1){
                            tSql.append("'"+tStr[0]+"')");
                        }else{
                            tSql.append("'"+tStr[0]+"',");
                        }
                }
            }
        }
        if(aVO.concentricityId != null && !aVO.concentricityId.trim().equals("")){
            tSql.append(" and a.GS_CONCENTRICITY_ID like '%" + aVO.concentricityId + "%'");
        }
        if(aVO.manufInfo != null){
            tSql.append(" and (b.GS_MANUFACTURE_NAME like '%" + aVO.manufInfo + "%'");
            tSql.append(" or b.GS_MANUFACTURE_TYPE like '%" + aVO.manufInfo + "%'");
            tSql.append(" or b.GS_MANUFACTURE_SPEC like '%" + aVO.manufInfo + "%'");
            tSql.append(" or b.GS_MANUFACTURE_BRAND like '%" + aVO.manufInfo + "%'");
            tSql.append(" or b.GS_APPENDER_PROPERTY like '%" + aVO.manufInfo + "%'");
            tSql.append(" or b.GS_MANUFACTURER_NAME like '%" + aVO.manufInfo +"%')");
        }
        if(aVO.manufType1!= null){
            if(aVO.manufType1.equals("0")){
                tSql.append(" and e.GS_MANUFACTURE_CATEGORY_ID like '%'");
            }else if(aVO.manufType2.equals("0")){
                tSql.append(" and (e.GS_MANUFACTURE_CATEGORY_ID1 ='" + aVO.manufType1 + "'");
                tSql.append(" or e.GS_MANUFACTURE_CATEGORY_ID='" + aVO.manufType1 + "')");
            }else if(aVO.manufType3.equals("0")){
                tSql.append(" and (e.GS_MANUFACTURE_CATEGORY_ID2 ='" + aVO.manufType2 + "'");
                tSql.append(" or e.GS_MANUFACTURE_CATEGORY_ID='" + aVO.manufType2 + "')");
            }else{
                tSql.append(" and e.GS_MANUFACTURE_CATEGORY_ID ='" + aVO.manufType3 + "'");
            }
        }
        return tSql.toString();
    }
    /**
     * 修改应急采购信息
     * @param aTempOrderBean        应急采购Bean对象
     * @param aOldStatus            原状态
     * @param aConn                 DB连接
     * @return
     * @throws GSException
     */
    public boolean updateTempOrderDetail(GSTempOrderBean aTempOrderBean,String aOldStatus,Connection aConn) throws GSException{
        boolean tFlag = false;
        StringBuffer tSql = new StringBuffer("update GS_ORDER_TEMP_DETAIL set GS_ORDER_DETAIL_STATUS='"+ aTempOrderBean.getOrderDetailStatus() + "'");
        if(aTempOrderBean.getSignInCount() != 0){
            tSql.append(",GS_SIGNIN_COUNT=" + aTempOrderBean.getSignInCount());
        }
        if(aTempOrderBean.getSignInPrice() != 0){
            tSql.append(",GS_SIGNIN_PRICE=" + aTempOrderBean.getSignInPrice());
        }
        tSql.append(" where GS_ORDER_DETAIL_ID='" + aTempOrderBean.getOrderDetailId() + "'");
        tSql.append(" and GS_ORDER_DETAIL_STATUS='" + aOldStatus + "'");
        try{
            tFlag = this.executeUpdate(aConn,tSql.toString(),null);
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19995,GSException.E19995_MSG);
        }
        return tFlag;
    }
    /**
     * 查询应急采购明细信息
     * @param aVO           参数VO对象
     * @param aConn         DB连接
     * @return
     * @throws GSException
     */
    public GSTempOrderBean queryTempOrderDetail(GSBusEmergencyOrderConfirmVO aVO,Connection aConn)throws GSException{
        String tSql = "select * from GS_ORDER_TEMP_DETAIL where GS_ORDER_DETAIL_ID=?";
        GSTempOrderBean tBean = null;
        Object[] tObj = new Object[1];
        tObj[0] = aVO.orderDetailId;
//        tObj[1] = aVO.deliverGoodsId;
        try{
            ArrayList tList = this.executeQuery(aConn,new GSTempOrderBean(),tSql,tObj);
            if(tList.size() == 1){
                tBean = (GSTempOrderBean)tList.get(0);                
            }
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);            
        }
        return tBean;
    }
    /**
     * 删除应急采购信息
     * @param aVO           参数VO对象
     * @param aConn         DB连接
     * @return
     * @throws GSException
     */
    public boolean deleteTempOrderDetail(GSBusEmergencyOrderConfirmVO aVO,Connection aConn) throws GSException{
        String tSql = "delete from GS_ORDER_TEMP_DETAIL where GS_ORDER_DETAIL_ID=?";
        Object[] tObj = new Object[1];
        tObj[0] = aVO.orderDetailId;
        boolean tFlag = false;
        try{
            tFlag = this.executeUpdate(aConn,tSql,tObj);
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19995,GSException.E19995_MSG);            
        }
        return tFlag;
    }
    /**
     * 查询应急采购订单明细
     * @param aOrderId          订单编号
     * @param aConn             DB连接
     * @return
     * @throws GSException
     */
    public ArrayList queryTempOrderDetail(String aOrderId,Connection aConn) throws GSException{
        ArrayList tList = new ArrayList();
        //查询SQL
        StringBuffer tSql = new StringBuffer("select distinct a.GS_ORDER_DETAIL_ID as P1,a.GS_CONCENTRICITY_ID as P2,");
        tSql.append("b.GS_MANUFACTURE_NAME as P3,b.GS_MANUFACTURE_SPEC as P4,b.GS_MANUFACTURE_TYPE as P5,");
        tSql.append("b.GS_MANUFACTURE_BRAND as P6,c.GS_PROVIDER_SHORTNAME as P7,");
        tSql.append("a.GS_ORDER_COUNT as P8,b.GS_QUANT_UNIT as P9,a.GS_GOODS_UNITPRICE as P10,");
        tSql.append("a.GS_ORDER_TEMPID as P11,b.GS_IS_TRADEFLAT_MANUFACTURE as P12,c.GS_PROVIDER_ID as P13,");
        tSql.append("c.GS_IS_TRADEFLAT_PROVIDER as P14,a.GS_SIGNIN_PRICE as P15,a.GS_SIGNIN_COUNT as P16 ");
        tSql.append("from GS_ORDER_TEMP_DETAIL a,GS_MANUFACTURE b,GS_PROVIDER c ");
        tSql.append("where a.GS_ORDER_TEMPID='"+ aOrderId + "' and a.GS_CONCENTRICITY_ID=b.GS_CONCENTRICITY_ID ");
        tSql.append("and c.GS_PROVIDER_ID=a.GS_PROVIDER_ID ");
        tSql.append("and a.gs_manufacture_id=b.gs_manufacture_id ");
        try{
            tList = this.executeQuery(aConn,new GSBusEmergencyOrderConfirmDetailVO(),tSql.toString(),null);
        }catch(Exception e){
            GSLogWriter.error(this,e.toString());
            throw new GSException(GSException.E19999,GSException.E19999_MSG);            
        }
        return tList;
    }
}
